<template>
  <div style="background:#BBE6F7">
     <el-row style="background:#ccc;height:80px;line-height:80px;padding: 0px 0 10px 20px;">
        <el-radio-group v-model="tabIndex" @change="jumpInfo">
          <el-radio-button :label="1" name="1">预警详情</el-radio-button>
          <el-radio-button v-if="userPageAuth.carmileageconfig" :label="2" name="2">车辆里程预警配置</el-radio-button>
          <el-radio-button v-if="userPageAuth.cartimeconfig" :label="3" name="3">车辆时间预警配置</el-radio-button>
          <el-radio-button v-if="userPageAuth.personconfig" :label="4" name="4">人员预警配置</el-radio-button>
        </el-radio-group>
    </el-row>
    <noAuth :createFun="createFun">
      <el-row style="padding:10px 50px 30px;">
        <el-col :span="24">
          <div style="margin: 20px 0 30px">
            <el-button size="mini" @click="search">搜索</el-button>
            <el-button size="mini" @click="reset">重置</el-button>
            <el-button size="mini" @click="add">增加</el-button>
            <el-button size="mini" @click="save">保存</el-button>
          </div>
          <el-table
            :data="recordSearchObj"
            :border="true"
            :header-cell-style="{background:'#eef1f6',color:'#606266','text-align': 'center'}"
            class="customTableStyle"
            style="font-size:12px;">
            <el-table-column
              label="编号"
              min-width="80"
              type="index" />
            <el-table-column
              label="车牌号"
              min-width="110">
              <template slot-scope="scope">
                <el-input size="mini" v-model="scope.row.cph" placeholder="请输入内容"></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="基础维保里程(万公里)"
              min-width="120">
              <template slot-scope="scope">
                <el-input size="mini" type="number" v-model="scope.row.jcwblc" placeholder="请输入内容"></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="预警项目"
              min-width="120">
              <template slot-scope="scope">
                <!-- <el-input size="mini" v-model="scope.row.yjxm" placeholder="请输入内容"></el-input> -->
                <el-select size="mini" clearable v-model="scope.row.yjxm" placeholder="请选择">
                  <el-option
                    v-for="item in yjxmList"
                    :key="item.id"
                    :label="item.yjxm"
                    :value="item.yjxm">
                  </el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column
              label="预警类别"
              min-width="80">
              <template slot-scope="scope">
                <!-- <el-input size="mini" v-model="scope.row.yjlb" placeholder="请输入内容"></el-input> -->
                <el-select size="mini" clearable v-model="scope.row.yjlb" placeholder="请选择">
                  <el-option label="里程" value="里程"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column
              label="预警间隔(万公里)"
              min-width="80">
              <template slot-scope="scope">
                <el-input size="mini" type="number" v-model="scope.row.yjjg" placeholder="请输入内容"></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="备注"
              min-width="140">
              <template slot-scope="scope">
                <el-input size="mini" v-model="scope.row.bz" placeholder="请输入内容"></el-input>
              </template>
            </el-table-column>
            <el-table-column
              label="操作"
              min-width="150">
              <!-- <template slot-scope="scope">
                <el-input size="mini" disabled></el-input>
              </template> -->
            </el-table-column>
          </el-table>
          <el-pagination
            :total="page.totalCount"
            :page-size="page.pageSize"
            :current-page.sync="page.currPage"
            style="margin-top: 10px;"
            background
            layout="total, slot, prev, pager, next"
            @current-change="search">
            <span>—&nbsp;&nbsp;&nbsp;共 {{page.totalPage}} 页</span>
          </el-pagination>
          <div v-if="addVisi" style="margin-top: 20px">
            <el-row>
              <el-col :span="24">
                <el-card class="box-card">
                  <div slot="header" class="clearfix" style="font-size:14px">
                    <span>增加</span>
                    <el-button style="float: right;font-size:12px; padding: 7px 15px;margin-left:10px" type="text" @click="addClick">保存</el-button>
                    <el-button style="float: right;font-size:12px; padding: 7px 15px" type="text" @click="addVisi = false">取消</el-button>
                  </div>
                  <div>
                    <el-table
                      :data="adddata"
                      :border="true"
                      :header-cell-style="{background:'#eef1f6',color:'#606266','text-align': 'center'}"
                      class="customTableStyle"
                      style="font-size:12px;">
                      <el-table-column
                        label="编号"
                        min-width="80"
                        type="index"/>
                      <el-table-column
                        label="车牌号"
                        min-width="110">
                        <template slot-scope="scope">
                          <el-input size="mini" v-model="scope.row.cph" placeholder="请输入内容"></el-input>
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="基础维保里程(万公里)"
                        min-width="120">
                        <template slot-scope="scope">
                          <el-input size="mini" type="number" v-model="scope.row.jcwblc" placeholder="请输入内容"></el-input>
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="预警项目"
                        min-width="120">
                        <template slot-scope="scope">
                          <el-select size="mini" clearable v-model="scope.row.yjxm" placeholder="请选择">
                            <el-option
                              v-for="item in yjxmList"
                              :key="item.id"
                              :label="item.yjxm"
                              :value="item.yjxm">
                            </el-option>
                          </el-select>
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="预警类别"
                        min-width="80">
                        <template slot-scope="scope">
                          <el-input size="mini" v-model="scope.row.yjlb" placeholder="请输入内容"></el-input>
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="预警间隔(万公里)"
                        min-width="80">
                        <template slot-scope="scope">
                          <el-input size="mini" type="number" v-model="scope.row.yjjg" placeholder="请输入内容"></el-input>
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="备注"
                        min-width="140">
                        <template slot-scope="scope">
                          <el-input size="mini" v-model="scope.row.bz" placeholder="请输入内容"></el-input>
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="操作"
                        min-width="150">
                        <!-- <template slot-scope="scope">
                          <el-input size="mini" disabled></el-input>
                        </template> -->
                      </el-table-column>
                    </el-table>
                  </div>
                </el-card>
              </el-col>
            </el-row>
          </div>
          <el-table
            :data="page.list"
            :border="true"
            :header-cell-style="{background:'#eef1f6',color:'#606266','text-align': 'center'}"
            highlight-current-row
            @row-click="rowClick"
            class="customTableStyle"
            style="font-size:12px;">
            <el-table-column
              type="index"
              label="编号"
              min-width="80"/>
            <el-table-column
              label="车牌号"
              min-width="110">
              <template slot-scope="scope">
                <div v-if="editVisi && scope.row.id == editdata.id">
                  <el-input size="mini" v-model="editdata.cph" placeholder="请输入内容"></el-input>
                </div>
                <div v-else>{{ scope.row.cph }}</div>
              </template>
            </el-table-column>
            <el-table-column
              label="基础维保里程(万公里)"
              min-width="120">
              <template slot-scope="scope">
                <div v-if="editVisi && scope.row.id == editdata.id">
                  <el-input size="mini" v-model="editdata.jcwblc" placeholder="请输入内容"></el-input>
                </div>
                <div v-else>{{ scope.row.jcwblc }}</div>
              </template>
            </el-table-column>
            <el-table-column
              label="预警项目"
              min-width="120">
              <template slot-scope="scope">
                <div v-if="editVisi && scope.row.id == editdata.id">
                  <el-select size="mini" clearable v-model="editdata.yjxm" placeholder="请选择">
                    <el-option
                      v-for="item in yjxmList"
                      :key="item.id"
                      :label="item.yjxm"
                      :value="item.yjxm">
                    </el-option>
                  </el-select>
                </div>
                <div v-else>{{ scope.row.yjxm }}</div>
              </template>
            </el-table-column>
            <el-table-column
              label="预警类别"
              min-width="80">
              <template slot-scope="scope">
                <div v-if="editVisi && scope.row.id == editdata.id">
                  <el-input size="mini" v-model="editdata.yjlb" placeholder="请输入内容"></el-input>
                </div>
                <div v-else>{{ scope.row.yjlb }}</div>
              </template>
            </el-table-column>
            <el-table-column
              label="预警间隔(万公里)"
              min-width="80">
              <template slot-scope="scope">
                <div v-if="editVisi && scope.row.id == editdata.id">
                  <el-input size="mini" v-model="editdata.yjjg" placeholder="请输入内容"></el-input>
                </div>
                <div v-else>{{ scope.row.yjjg }}</div>
              </template>
            </el-table-column>
            <el-table-column
              label="备注"
              min-width="140">
              <template slot-scope="scope">
                <div v-if="editVisi && scope.row.id == editdata.id">
                  <el-input size="mini" v-model="editdata.bz" placeholder="请输入内容"></el-input>
                </div>
                <div v-else>{{ scope.row.bz }}</div>
              </template>
            </el-table-column>
            <el-table-column
              label="操作"
              min-width="150">
              <template slot-scope="scope">
                <div>
                  <el-button size="mini" @click="edit(scope.row)">修改</el-button>
                  <el-button size="mini" @click="deleteClick(scope.row.id)">删除</el-button>
                </div>
              </template>
            </el-table-column>
          </el-table>
        </el-col>
      </el-row>   
    </noAuth>
  </div>
</template>

<script>
import noAuth from '@/components/noAuth'
import {selectWarnProject} from "@/api/api"
import adapter from './adapter'
export default {
  name: '',
  data() { 
    return {
      tabIndex:2,
      ...adapter.data,
    }
  },
  components: {
    noAuth,
  },
  computed: {
    ...adapter.computed,
  },
  created() {
    this.initPage()
  },
  mounted() {
    
  },
  methods:{
    ...adapter.methods,
    createFun() {
      this.initwarnDetailsList()
      //获取预警项目
      selectWarnProject().then((res)=>{
        console.log(res.data.list)
        this.yjxmList = res.data.list
      })
    },
    jumpInfo(tabIndex) {
      console.log(tabIndex)
      if(tabIndex == 1){
        this.$router.push('details')
      }else if (tabIndex == 2) {
        this.$router.push('carmileageconfig')
      }else if(tabIndex ==3){
        this.$router.push('cartimeconfig')
      }else{
        this.$router.push('personconfig')
      }
    },
  },
 }
</script>

<style  lang="scss" scope>
.car-detail-title{
  font-size: 30px;
  text-align: center;
}

.el-radio-button__inner{
  padding: 10px 20px;
}
</style>